<?php

namespace App\Http\Requests;

use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class CommentSaveRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            "post_id" => ["required", Rule::exists("tb_posts", "post_id")],
            "parent_id" => ["nullable", Rule::exists("tb_comment", "comm_id")],
            "comm_content" => ["required"],
            "comm_is_show" => ["required", "integer", "min:0", "max:1"],
            "comm_name" => ["required"],
            "comm_email" => ["required"]
        ];
    }
}
